/**
 * Iroh integration for React Native
 *
 * This module provides a React Native-compatible interface to iroh functionality.
 * Since the official @number0/iroh package is designed for Node.js, we provide
 * alternative implementations that work in React Native environment.
 */

export interface IrohConfig {
  nodeId?: string;
  relayUrl?: string;
  discoveryMode?: "local" | "relay" | "both";
}

export interface IrohDocument {
  id: string;
  name: string;
  size: number;
  created: Date;
  modified: Date;
}

export interface IrohBlob {
  hash: string;
  size: number;
  format: "raw" | "hash-seq";
}

export interface IrohNode {
  id: string;
  isConnected: boolean;
  documents: IrohDocument[];
}

export interface FileTransferProgress {
  transferred: number;
  total: number;
  percentage: number;
  status: "pending" | "transferring" | "completed" | "error";
}

export interface IrohClient {
  // Node management
  createNode(config?: IrohConfig): Promise<IrohNode>;
  getNodeInfo(): Promise<IrohNode>;
  shutdown(): Promise<void>;

  // Document operations
  createDocument(name: string): Promise<IrohDocument>;
  getDocument(id: string): Promise<IrohDocument | null>;
  listDocuments(): Promise<IrohDocument[]>;
  deleteDocument(id: string): Promise<boolean>;

  // Blob operations
  addBlob(data: Uint8Array): Promise<IrohBlob>;
  getBlob(hash: string): Promise<Uint8Array | null>;

  // File operations
  addFile(filePath: string): Promise<IrohBlob>;
  exportFile(hash: string, outputPath: string): Promise<boolean>;

  // Network operations
  connect(nodeId: string): Promise<boolean>;
  disconnect(nodeId: string): Promise<boolean>;
  listConnections(): Promise<string[]>;

  // Transfer operations
  shareDocument(documentId: string): Promise<string>; // Returns share ticket
  receiveDocument(
    ticket: string,
    onProgress?: (progress: FileTransferProgress) => void,
  ): Promise<IrohDocument>;
}

// Export the main client implementation
export { IrohClientImpl } from "./client";
export { IrohUtils } from "./utils";

